/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package games.kamisado;

import games.KamisadoSquare;
import games.KamisadoState;
import java.util.ArrayList;
import java.util.Iterator;
import games.KamisadoState.KamisadoMove;
import games.SquareColor;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.junit.Test;
import static org.junit.Assert.*;

public class KamisadoMoveAndBacktrackTest {

    @Test
    public void move_moveBrownFromX0Y0ToX0Y1_towerHasMovedAndOldCellIsClear() throws FileNotFoundException, IOException {
        KamisadoState state = new KamisadoState();

        Iterator<KamisadoMove> result = state.moves();
        state.move(result.next());
       
        KamisadoSquare cell = state.cell(0, 6);
        KamisadoSquare oldCell = state.cell(0, 7);
        
        assertNull(oldCell.getTower());
        assertEquals(SquareColor.ORANGE, cell.getTower().getColor());

    }
    
    @Test
    public void move_moveBrownFromX0Y0ToX0Y1AndBackTrack_towerIsBackAtStartAndCellIsClear() throws FileNotFoundException, IOException {
        KamisadoState state = new KamisadoState();

        Iterator<KamisadoMove> result = state.moves();
        state.move(result.next());
        state.backtrack();
       
        KamisadoSquare cell = state.cell(0, 6);
        KamisadoSquare oldCell = state.cell(0, 7);
        
        assertNull(cell.getTower());
        assertEquals(SquareColor.ORANGE, oldCell.getTower().getColor());

    }

}
